package com.bigdata;

import java.util.LinkedHashMap;
import java.util.Map;

class LRUCache {
    public Cache c ;
    public LRUCache(int capacity) {
        c = new Cache(capacity);
    }

    public int get(int key) {
        Integer res = c.get(key);
        System.out.println("get: " + key);
        if (res == null) {
            return -1;
        }
        return c.get(key);
    }

    public void put(int key, int value) {
        System.out.println("put " + key);
        c.put(key, value);
    }
}

class Cache extends LinkedHashMap<Integer, Integer> {
    public int sizeL;
    @Override
    protected boolean removeEldestEntry(Map.Entry<Integer, Integer> eldest) {
        return size() > sizeL;
    }

    public Cache(int size) {
        super(size, 0.75f, true);
        this.sizeL = size;
    }
}

